"use server"


import {CreateRoleFormSchema} from "@/lib/zod/schema";
import {z} from "zod";
import {safeAction} from "@/lib/action/safe-action";
import {ActionState} from "@/lib/zod/types";
import db from "@/lib/db";



const collbak = async (state:ActionState<z.infer<typeof CreateRoleFormSchema>>, data:z.infer<typeof CreateRoleFormSchema>, )=>{
    await db.roles.create({
        data:{...data,updatedAt:new Date()}
    });
    return {
        code:200,
        msg:"新建成功"
    };
};


export const createRole = safeAction<z.infer<typeof CreateRoleFormSchema>>(CreateRoleFormSchema,collbak);